Skip to content

Implement fs.glob, fs.globSync, and fs/promises.glob#6378

Open
fraidev wants to merge 5 commits intocloudflare:mainfrom
fraidev:feat/implement-fs-glob
Open

Implement fs.glob, fs.globSync, and fs/promises.glob#6378
fraidev wants to merge 5 commits intocloudflare:mainfrom
fraidev:feat/implement-fs-glob

Conversation

@fraidev
Copy link

@fraidev fraidev commented Mar 22, 2026

Implements the Node.js fs.glob APIs that were previously stubbed with ERR_UNSUPPORTED_OPERATION. Uses a custom glob-to-regex pattern matcher.

Closes #5416

fraidev added 3 commits March 21, 2026 22:59
Implements the Node.js fs.glob APIs that were previously stubbed with
ERR_UNSUPPORTED_OPERATION. Uses a custom glob-to-regex pattern matcher
instead of the minimatch library which is unavailable in the Workers
runtime.

Closes cloudflare#5416
@github-actions
Copy link

github-actions bot commented Mar 22, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@fraidev
Copy link
Author

fraidev commented Mar 22, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Mar 22, 2026
@jasnell
Copy link
Collaborator

jasnell commented Mar 23, 2026

Hey @fraidev! thank you for this! I've done a first pass look over and have asked the AI agent to review also.. it should post it's findings in a moment. How closely does this follow the node.js implementation? (I haven't looked at it in a while) Is it a straight up port of the original or did you reimplement? The main reason I ask is that if it is a straight port over, we might need to carry over the Node.js copyright/license detail in the header of the new file(s).

Copy link
Collaborator

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Note: This review was generated by an AI assistant (Claude) and may contain inaccuracies. Please evaluate each suggestion on its merits.

Findings (6):

  • [HIGH] exclude type handling — unsafe cast in compileExclude when exclude is a user function
  • [MEDIUM] ** in middle of exclude pattern doesn't match zero segments (a/**/b won't match a/b)
  • [MEDIUM] walkGlob has unbounded recursion depth — no depth guard
  • [MEDIUM] Non-null assertions (!) used extensively — violates ts-style convention
  • [MEDIUM] Missing callback guard in fs.glob — throws when callback omitted
  • [LOW] Copyright year says 2017-2022 in new file

@fraidev
Copy link
Author

fraidev commented Mar 24, 2026

Hey @fraidev! thank you for this! I've done a first pass look over and have asked the AI agent to review also.. it should post it's findings in a moment. How closely does this follow the node.js implementation? (I haven't looked at it in a while) Is it a straight up port of the original or did you reimplement? The main reason I ask is that if it is a straight port over, we might need to carry over the Node.js copyright/license detail in the header of the new file(s).

Hey @jasnell! This is a reimplementation, not a port. Node.js uses minimatch internally, which isn't available in the Workers runtime, so I built glob-to-regex to convert and pattern-driven directory walker from scratch.
The test patterns and fixture structure are derived from Node.js's test-fs-glob.mjs to verify compatibility, but the implementation shares no code with Node.js.

@fraidev
Copy link
Author

fraidev commented Mar 24, 2026

@jasnell is there a way to run CI for a non-Cloudflare member?

@fraidev fraidev requested a review from jasnell March 24, 2026 00:08
@fraidev fraidev changed the title Feat/implement fs glob Implement fs.glob, fs.globSync, and fs/promises.glob Mar 24, 2026
@jasnell
Copy link
Collaborator

jasnell commented Mar 24, 2026

Just did. Internal_build will fail but I'll run that one manually

@fraidev
Copy link
Author

fraidev commented Mar 24, 2026

Just did. Internal_build will fail but I'll run that one manually

Great! I fixed ESLint errors. I think that we need one more run.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.65%. Comparing base (cea70af) to head (01b5da0).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6378      +/-   ##
==========================================
- Coverage   70.80%   70.65%   -0.16%     
==========================================
  Files         424      425       +1     
  Lines      115290   116825    +1535     
  Branches    18751    18880     +129     
==========================================
+ Hits        81629    82538     +909     
- Misses      22429    23043     +614     
- Partials    11232    11244      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fraidev fraidev marked this pull request as ready for review March 24, 2026 18:49
@fraidev fraidev requested review from a team as code owners March 24, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nodejs compat: implement fs.glob

3 participants